package com.hr.jobTimeRecord.service.impl;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.hr.jobTimeRecord.mapper.JobTimeRecordMapper;
import com.hr.jobTimeRecord.domain.JobTimeRecord;
import com.hr.jobTimeRecord.service.IJobTimeRecordService;

import javax.annotation.Resource;

/**
 * 员工入职时间记录Service业务层处理
 * 
 * @author guan
 * @date 2024-07-16
 */
@Service
public class JobTimeRecordServiceImpl implements IJobTimeRecordService 
{
    @Resource
    private JobTimeRecordMapper jobTimeRecordMapper;

    /**
     * 查询员工入职时间记录
     * 
     * @param userId 员工入职时间记录主键
     * @return 员工入职时间记录
     */
    @Override
    public JobTimeRecord selectJobTimeRecordByUserId(Long userId)
    {
        return jobTimeRecordMapper.selectJobTimeRecordByUserId(userId);
    }

    /**
     * 查询员工入职时间记录列表
     * 
     * @param jobTimeRecord 员工入职时间记录
     * @return 员工入职时间记录
     */
    @Override
    public List<JobTimeRecord> selectJobTimeRecordList(JobTimeRecord jobTimeRecord)
    {
        return jobTimeRecordMapper.selectJobTimeRecordList(jobTimeRecord);
    }

    /**
     * 新增员工入职时间记录
     * 
     * @param jobTimeRecord 员工入职时间记录
     * @return 结果
     */
    @Override
    public int insertJobTimeRecord(JobTimeRecord jobTimeRecord)
    {
        return jobTimeRecordMapper.insertJobTimeRecord(jobTimeRecord);
    }

    /**
     * 修改员工入职时间记录
     * 
     * @param jobTimeRecord 员工入职时间记录
     * @return 结果
     */
    @Override
    public int updateJobTimeRecord(JobTimeRecord jobTimeRecord)
    {
        return jobTimeRecordMapper.updateJobTimeRecord(jobTimeRecord);
    }

    /**
     * 批量删除员工入职时间记录
     * 
     * @param userIds 需要删除的员工入职时间记录主键
     * @return 结果
     */
    @Override
    public int deleteJobTimeRecordByUserIds(Long[] userIds)
    {
        return jobTimeRecordMapper.deleteJobTimeRecordByUserIds(userIds);
    }

    /**
     * 删除员工入职时间记录信息
     * 
     * @param userId 员工入职时间记录主键
     * @return 结果
     */
    @Override
    public int deleteJobTimeRecordByUserId(Long userId)
    {
        return jobTimeRecordMapper.deleteJobTimeRecordByUserId(userId);
    }

    /**
     * 查询员工入职时间记录数量
     * @param jobTimeRecord 员工入职时间记录
     * @return
     */
    @Override
    public JobTimeRecord selectJobTimeRecordCount(JobTimeRecord jobTimeRecord) {
        List<Date> times = jobTimeRecord.getTimes();
        SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd");
        jobTimeRecord.setStartDate(sf.format(times.get(0)));
        jobTimeRecord.setEndDate(sf.format(times.get(1)));
        return jobTimeRecordMapper.selectJobTimeRecordCount(jobTimeRecord);
    }

    /**
     * 查询员工入职时间记录数量Def
     * @param jobTimeRecord
     * @return
     */
    @Override
    public JobTimeRecord selectJobTimeRecordCountDef(JobTimeRecord jobTimeRecord) {
        return jobTimeRecordMapper.selectJobTimeRecordCountDef(jobTimeRecord);
    }
}
